package com.hundsun.aitest.common;

import java.util.HashMap;
import java.util.Map;

public enum DirNameEnum {
    FK("FK","风控"),
    CW("CW","财务"),
    CP("CP","产品"),
    JG("JG","机构"),
    TZ("TZ","投资"),
    ZTQK("ZTQK","ZTQK"),
    XS("XS","销售"),
    HG("HG","合规"),
    HR("HR","互认"),
    JW("JW","境外"),
    ZG("ZG","资管");

    private final String code;
    private final String displayName;

    DirNameEnum(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    public String getCode() {
        return code;
    }

    public String getDisplayName() {
        return displayName;
    }

    // 用于通过 code 获取对应的枚举实例
    private static final Map<String, DirNameEnum> BY_CODE = new HashMap<>();

    static {
        for (DirNameEnum dirName : values()) {
            BY_CODE.put(dirName.getCode(), dirName);
        }
    }

    public static DirNameEnum fromCode(String code) {
        return BY_CODE.get(code.toUpperCase());
    }

    // 提供一个辅助方法，直接返回 displayName
    public static String getDisplayNameByCode(String code) {
        DirNameEnum dirName = fromCode(code);
        return dirName != null ? dirName.getDisplayName() : null;
    }
}
